<%--
  Created by IntelliJ IDEA.
  User: 86181
  Date: 2022/11/25
  Time: 10:34
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>生产登记复核显示页面</title>
</head>
<body>
<div class="row">
    <div class="col-md-offset-10"><button onclick="outbtnshow()" class="btn btn-primary">返回</button></div>
</div>
<br>
<div align="center" style="width:1200px;height:1000px;border:1px black solid">
    <div class="row">
        <div><h2><strong>生产登记单</strong></h2></div>
        <input type="hidden" id="produktonidshow">
    </div>
    <br>
    <div class="row">
        <div class="col-md-6">
            <table>
                <tr>
                    <td>派工单编号:</td>
                    <td><input type="text" readonly id="dispatchmanufactureIdshow" name="manufactureId"  style="outline: none;border: none;background-color:white;border-radius:20px;height:35px"></td>
                </tr>
                <tr>
                    <td>产品编号:</td>
                    <td><input type="text" id="dispatchproductIdshow" name="productId" readonly  style="outline: none;border: none;background-color:white;border-radius:20px;height:35px"></td>
                </tr>
                <tr>
                    <td>描述:</td>
                    <td><input type="text" readonly id="dispatchproductDescribeshow" name="productDescribe"  style="outline: none;border: none;background-color:white;border-radius:20px;height:35px"></td>
                </tr>
            </table>
        </div>
        <div class="col-md-6">
            <table>
                <tr>
                    <td>出库单编号:</td>
                    <td><input type="text" id="dispatchshow" name="" readonly  style="outline: none;border: none;border-radius:20px;height:35px"></td>
                </tr>
                <tr>
                    <td>产品名称:</td>
                    <td><input type="text" id="dispatchproductNameshow" name="productName" readonly  style="outline: none;border: none;background-color:white;border-radius:20px;height:35px"></td>
                </tr>
                <tr>
                    <td>数量:</td>
                    <td><input type="text" id="dispatchamountshow" name="amount" readonly  style="outline: none;border: none;background-color:white;border-radius:20px;height:35px"></td>
                </tr>
            </table>
        </div>
    </div>
    <br>
    <div  style="height:25%">
        <div class="row">
            <div class="col-md-offset-10"><button class="btn btn-default" onclick="jiazaishow()"><span class="glyphicon glyphicon-refresh"></span></button></div>
        </div>
        <table id="produktionsregistrierungDispatchtabshow">

        </table>
    </div>
    <br>
    <div class="row">
        <div class="col-md-6">
            <table>
                <tr>
                    <td>设计工时总成本:</td>
                    <td><input type="text" name="labourCostPriceSum" id="dispatchlabourCostPriceSumshow" readonly style="outline: none;border: none;background-color:white;border-radius:20px;height:35px"></td>
                </tr>
                <tr>
                    <td>实际工时总成本:</td>
                    <td><input type="text" id="dispatchrealLabourCostPriceSumshow" name="realLabourCostPriceSum" readonly style="outline: none;border: none;background-color:white;border-radius:20px;height:35px"></td>
                </tr>
                <tr>
                    <td>登记人:</td>
                    <td><input type="text" id="dispatchregistershow" name="register" readonly style="outline: none;border: none;background-color:white;border-radius:20px;height:35px"></td>
                </tr>
                <tr>
                    <td>复核人:</td>
                    <td><input type="text" id="dispatchcheckershow" name="checker" readonly style="outline: none;border: none;background-color:white;border-radius:20px;height:35px"></td>
                </tr>
            </table>
        </div>
        <div class="col-md-6">
            <table>
                <tr>
                    <td>设计物料总成本:</td>
                    <td><input type="text" id="dispatchmoduleCostPriceSumshow" name="moduleCostPriceSum" readonly style="outline: none;border: none;background-color:white;border-radius:20px;height:35px"></td>
                </tr>
                <tr>
                    <td>实际物料总成本:</td>
                    <td><input type="text" id="dispatchrealModuleCostPriceSumshow" name="realModuleCostPriceSum" readonly style="outline: none;border: none;background-color:white;border-radius:20px;height:35px"></td>
                </tr>
                <tr>
                    <td>登记时间:</td>
                    <td><input type="text" id="dispatchregisterTimeshow" name="registerTime" readonly style="outline: none;border: none;background-color:white;border-radius:20px;height:35px"></td>
                </tr>
                <tr>
                    <td>复核时间:</td>
                    <td><input type="text" id="dispatchcheckTimeshow" name="checkTime" readonly style="outline: none;border: none;background-color:white;border-radius:20px;height:35px"></td>
                </tr>
            </table>
        </div>
    </div>
    <br>
    <div>
        <div class="form-group">
            <label for="dispatch-textshow"  class="control-label">配置要求:</label>
            <textarea class="form-control" readonly name="remark" id="dispatch-textshow" style="width:800px;height:200px;background-color:gainsboro;"></textarea>
        </div>
    </div>
</div>
<!--审核登记模态框-->
<div class="modal fade"  tabindex="-1" role="dialog" aria-labelledby="gridSystemModalLabel" id="produktionsregistrierungDispatchrexamineshowmodal">
    <div class="modal-dialog modal-lg">
        <div class="modal-content" id="produktionsregistrierungDispatchrexamineshowmodalson">

        </div>
    </div>
</div>
<div class="modal fade"  tabindex="-1" role="dialog" aria-labelledby="gridSystemModalLabel" id="handoverreviewmodal">
    <div class="modal-dialog modal-lg">
        <div class="modal-content">
            <div class="modal-header">
                <button class="close" data-dismiss="modal">退出</button>
                <input type="button" onclick="handoverreviewbtn()" value="复核" class="btn btn-default">
                <input type="hidden" id="detailsNumbermodal">
                <input type="hidden" id="idproduktionamodal">
            </div>
            <div class="modal-body" >
                <div>
                    <strong><span style="color:deepskyblue">您正在做的业务是：生产管理--内部生产管理--产登记复核</span></strong>
                </div>
                <br>
                <br>
                <br>
                <br>
                <br>
                <div class="input-group" align="center">
                    <span class="input-group-addon" id="basic-addonhandrevie">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;本工序投产数量&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
                    <input type="text"  readonly class="form-control" id="handnumrevie"  aria-describedby="basic-addonhandrevie">
                </div>
                <br>
                <br>
                <div class="input-group" align="center">
                    <span class="input-group-addon" id="basic-addonhandrevies">请输入本次工序合格数量</span>
                    <input type="text" class="form-control" id="handnumrevies"  aria-describedby="basic-addonhandrevies">
                </div>
                <div style="height: 300px">

                </div>
            </div>
        </div>
    </div>
</div>
        <script>
            //加载表格数据
            //加载表格数据
            $(function () {
                //加载表格数据
                $("#produktionsregistrierungDispatchtabshow").bootstrapTable({
                    sidePagination:"server", //分页方式：client客户端分页，server服务端分页（*）
                    showColumns: true,//是否显示所有的列（选择显示的列）
                    minimumCountColumns: 2,//最少允许的列数
                    showToggle: true,//是否显示详细视图和列表视图的切换按钮
                    cardView: false,//是否显示详细视图
                    detailView: false,//是否显示父子表,
                    columns:[
                        {
                            field:"",
                            title:"序号",
                            formatter:function (value,row,index) {
                                return Number(index)+1
                            }
                        },
                        {
                            field:"procedureName",
                            title:"工序名称",
                        },
                        {
                            field:"labourHourAmount",
                            title:"设计工时数",
                        },
                        {
                            field:"realLabourHourAmount",
                            title:"实际工时数",
                        }, {
                            field:"subtotal",
                            title:"设计工时成本(元)",
                        },
                        {
                            field:"realSubtotal",
                            title:"实际工时成本",
                        },
                        {
                            field:"moduleSubtotal",
                            title:"设计物料成本(元)",
                        },
                        {
                            field:"realModuleSubtotal",
                            title:"实际物料成本",
                        }, {
                            field:"procedureFinishTag",
                            title:"工序登记",
                            formatter:function (value,row,index) {
                                if(row.procedureFinishTag=="G004-0"){
                                    return "<a></a>"
                                }
                                if(row.procedureFinishTag=="G004-1"){
                                    return "<strong><a  style='color:deepskyblue' onclick='produktionsregistrierungDispatchckshow("+row.id+")'>登记复核</a></strong>"
                                }
                                if(row.procedureFinishTag=="G004-2"){
                                    return "<strong>登记复核</strong>"
                                }
                                if(row.procedureFinishTag=="G004-3"){
                                    return "<a>完成</a>"
                                }
                            }
                        },
                        {
                            field:"procedureTransferTag",
                            title:"工序交接",
                            formatter:function (value,row,index) {
                                if(row.procedureTransferTag=="G005-0"){
                                    return "<a></a>"
                                }
                                if(row.procedureTransferTag=="G005-1"){
                                    return "<strong><a  style='color:deepskyblue' onclick='handoverregistrationmobtn("+row.demandAmount+","+row.id+","+row.procedureId+")'>交接复核</a></strong>"
                                }
                                if(row.procedureTransferTag=="G005-2"){
                                    return "<a>完成</a>"
                                }
                            }
                        },
                    ],
                })
                aloshow()
            })
            function aloshow() {
                //获取id
                var manufactureId='${param.manufactureId}'
                //根据当前id查询
                $.post("queryByMmanufacturebymanufactureId.action",{"manufactureId":manufactureId},function (data) {
                    //赋值
                    //id
                    $("#produktonidshow").val(data.id)
                    //派工单编号
                    $("#dispatchmanufactureIdshow").val(data.manufactureId)
                    //产品编号
                    $("#dispatchproductIdshow").val(data.productId)
                    //描述
                    $("#dispatchproductDescribeshow").val(data.productDescribe)
                    //产品名称
                    $("#dispatchproductNameshow").val(data.productName)
                    //数量
                    $("#dispatchamountshow").val(data.amount)
                    //设计工时总成本
                    $("#dispatchlabourCostPriceSumshow").val(data.labourCostPriceSum)
                    //实际工时总成本
                    $("#dispatchrealLabourCostPriceSumshow").val(data.realLabourCostPriceSum)
                    //登记人
                    $("#dispatchregistershow").val(data.register)
                    //复核人
                    $("#dispatchcheckershow").val(data.checker)
                    //设计物料总成本
                    $("#dispatchmoduleCostPriceSumshow").val(data.moduleCostPriceSum)
                    //实际物料总成本
                    $("#dispatchrealModuleCostPriceSumshow").val(data.realModuleCostPriceSum)
                    //登记时间
                    $("#dispatchregisterTimeshow").val(data.registerTime)
                    //复核时间
                    $("#dispatchcheckTimeshow").val(data.checkTime)
                    //配置需求
                    $("#dispatch-textshow").val(data.remark)
                    //加载表格数据
                    //获取表格数据
                    var mprocedures=data.procedures;
                    var arr=[];
                    for (var i=0;i<mprocedures.length;i++){
                        arr.push(mprocedures[i])
                    }
                    //赋值
                    $("#produktionsregistrierungDispatchtabshow").bootstrapTable("load",arr)
                },"json")
            }
            function jiazaishow() {
                aloshow()
            }
            //放回
            function outbtnshow() {
                $("#tab1").addTabs("生产登记复核", "", "produktionsregistrierungDispatchrexamine.jsp", true);
                $("#tab1").closeTabs("生产登记生产复核单")
            }
            //审核
            function produktionsregistrierungDispatchckshow(id) {
                $("#produktionsregistrierungDispatchrexamineshowmodalson").load("produktionsregistrierungDispatchrexamineshowmodal.jsp",{"id":id,"dispatchmanufactureIdshow":$("#dispatchmanufactureIdshow").val()})
                $("#produktionsregistrierungDispatchrexamineshowmodal").modal("show")
            }
            //交接登记审核
            function handoverregistrationmobtn(demandAmount,id,procedureId) {
                $("#idproduktionamodal").val(id)
                $("#detailsNumbermodal").val(procedureId)
                $("#handnumrevie").val(demandAmount)
                $("#handnumrevies").val(demandAmount)
                $("#handoverreviewmodal").modal("show")
            }
            //复核
            function handoverreviewbtn() {
                 var i=0;
                var handnumrevie=$("#handnumrevie").val()
                var handnumrevies=$("#handnumrevies").val();
                if(Number(handnumrevie)<Number(handnumrevies)){
                    alert("合格数量不能大于生产数量")
                    i++;
                }

                var rel=/^[0-9]*$/
                if(!rel.test(handnumrevies)){
                    alert("请输入正确的数量")
                    i++;
                }
                if(i==0){
                    var manufactureId=$("#dispatchmanufactureIdshow").val()
                    var amout=$("#handnumrevies").val()
                    var detailsNumber=$("#detailsNumbermodal").val()
                    var id=$("#idproduktionamodal").val()
                    $.post("updateMprkcedhringshow.action",{"manufactureId":manufactureId,"amout":amout,"detailsNumber":detailsNumber,"id":id},function (data) {
                        alert(data.msg);
                        //关闭模态框
                        $("#handoverreviewmodal").modal("hide")
                        aloshow()
                    },"json")
                }
            }
        </script>
</body>
</html>
